// 防抖 执行最后一次 
export function debounce(fn, delay = 200) {
  let timer = null
  console.log(this)
  return function() {
    let arg = arguments
    timer && clearTimeout(timer)
    timer = setTimeout(() => {
      fn.apply(this, arg)
    }, delay)
  }
}
// 文件名 如 doc.png
export function getAssetsImages(name) {
  return new URL(`/src/assets/${name}`, import.meta.url).href;
}
// 数字补0
export  function addZero(num) {
  if (parseInt(num) < 10) {
    num = '0' + num
  }
  return num
}
export function deepClone(source) {
  let result = Array.isArray(source) ? [] : {}
  Object.keys(source).forEach(key => {
    if (source[key] && typeof source[key] === 'object') {
      result[key] = deepClone(source[key])
    } else {
      result[key] = source[key]
    }
  })
  return result
}